<?php
namespace app\mobile\controller;
use think\Controller;
use think\Controllers;
use think\Session;
use think\Cookie;
use think\Jump;
use think\Db;
class Index extends Controllers{

		public function index(){

			 $member = Session::get("user");
		   	 $person=DB::query("SELECT * FROM  ims_mc_members where uid='{$member['uid']}'")[0];
	   	     $me=DB::query("SELECT * FROM ims_xuan_zy_person  where uid='{$member['uid']}'")[0];
	   		 $gonggao=DB::query("SELECT * FROM  ims_xuan_zy_article where lanmu=-3 and  uniacid=2 order by id desc")[0];

		     $sql = "SELECT `logo`,`bankname`,`vir_number`,`id`,`tishi` FROM ims_xuan_zy_bank where status = 1  order by  rank desc limit 0,5";
		     $articles = DB::query($sql);
		     foreach ($articles as $key => &$v) {
		        http://kaka.5d305.cn/app/index.php?i=2&c=entry&op=detail&type=user&id=5&do=bank&m=xuan_zy
		        $v['url'] = "http://kaka.5d305.cn/app/index.php?i=2&c=entry&op=detail&id={$v['id']}&do=bank&m=xuan_zy";
		     }
		     $up1=DB::query("select * from ims_xuan_zy_userup where uid ='{$member['uid']}'")[0];
		     $uid =$member['uid'];
		     $sql = "select idcard from ims_xuan_zy_person where uid = {$uid}";
		     if(DB::query($sql)[0]['idcard']){
		        $type = 1;
		     } else {
		        $type = 0;
	   	     }
		     $caidans=DB::query("SELECT * FROM ims_xuan_zy_caidan where uniacid=2 and status=1  order by rank desc ");
		     $tou=DB::query("SELECT logo FROM ims_xuan_zy_huan where status=1 and type='首页头部2' and uniacid=2 order by rank desc");

			}
		public function upload(){
			 $flag=$_REQUEST['flag'];
		     $file = $_FILES['fileName'.$flag];//得到传输的数据

		    //得到文件名称
		    $name = $file['name'];
		    $type = strtolower(substr($name,strrpos($name,'.')+1)); //得到文件类型，并且都转化成小写
		    $allow_type = array('jpg','jpeg','gif','png'); //定义允许上传的类型
		    //判断文件类型是否被允许上传
		    if(!in_array($type, $allow_type)){
		        //如果不被允许，则直接停止程序运行
		        return ;
		    }
		    //判断是否是通过HTTP POST上传的
		    if(!is_uploaded_file($file['tmp_name'])){
		        //如果不是通过HTTP POST上传的
		        return ;
		    }

		    $upload_path = "../addons/xuan_zy/public/user/"; //上传文件的存放路径
		    $url=$upload_path.md5($file['name'].time()).'.'.$type;
		    //开始移动文件到相应的文件夹
		    if(move_uploaded_file($file['tmp_name'],$url)){
		    	echo json_encode(["data"=>true]);
		    }else{
		        echo "Failed!";
		    }

	}

	}
